import { FC, useRef, forwardRef } from "react";
import { ChatLoadMd } from "../ChatLoadDom";
import "./index.less";
import { Button, Dialog, Popup } from "@nutui/nutui-react";

interface IProps {
  open: boolean;
  formData: any;
  onCancel?: () => void;
}

const ModalContent = forwardRef(
  ({ formData }: Pick<IProps, "formData">, ref: any) => {
    return (
      <div className="chat-auto-report-modal-content">
        <div className="chat-auto-report-modal-body" ref={ref}>
          <div className="chat-auto-report-modal-content-t">装置体检报告</div>
          <div className="chat-auto-report-modal-content-d">
            {formData.createTime || ""}
          </div>
          <div className="markdown-body">
            <ChatLoadMd data={formData["step1"]}></ChatLoadMd>
          </div>
        </div>
      </div>
    );
  }
);

const ChatAotoReportModal: FC<IProps> = ({ open, formData, onCancel }) => {
  const contentRef = useRef<HTMLDivElement>(null);

  return (
    <Popup
      className="chat-redesign-report-modal"
      portal={document.body}
      visible={open}
      onClose={onCancel}
    >
      <ModalContent formData={formData} ref={contentRef}></ModalContent>
    </Popup>
  );
};

export default ChatAotoReportModal;
